home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1996 April / Macworld (1996-04).dmg / Shareware World / Entertainment / General / RW 4.1.2 / RoboWar 4.1.2 / RoboWar 4.1.2.rsrc / TEXT_2011_Samples.txt < prev    next >
Text File  |  1995-12-12  |  2KB  |  107 lines

  1. Appendix B:  Sample Robots
  2.  
  3. The following code segments are the programs for the four sample robots distributed with this disk, Stationary, DumBot, TimBot, and MoveBot:
  4.  
  5. # Robot Stationary
  6. # 12/30/89 By David Harris
  7.  
  8. main:
  9.     aim 10 + aim' store
  10.     main jump
  11.  
  12. ••••••••••••••••••••••••••••••••••••
  13.  
  14. {   
  15.     DumBot
  16.     Created 12/27/89 by David Harris
  17.  
  18.     This robot maintains shields, rotates its
  19.     turret, and fires when it finds a target.
  20. }
  21.  
  22. Main:
  23.     50 shield' store
  24.     aim 7 + aim' store
  25.     range 0 > 
  26.        missilesub if
  27.     main jump
  28.  
  29. MissileSub:
  30.     50 missile' store
  31.     return
  32.  
  33. ••••••••••••••••••••••••••••••••••••
  34.  
  35. #  Tim's Robot
  36. #
  37. #   Designed by the same person
  38. #   Who, at the present, due to the presence 
  39. #   of altogether too many Electric Monks,  
  40. #   believes that he is a banana and that Dodo
  41. #   is more powerful than Mac II, thereby
  42. #   causing his programming ability to
  43. #   deteriorate.  Oh well.
  44.  
  45.     random aim' store
  46.  
  47. Main:
  48.     range 0 = rotate shoot ife
  49.     main jump
  50.  
  51. rotate:
  52.     aim 17 + aim' store
  53.     return
  54.  
  55. shoot:
  56.     energy 20 > reallyshoot if
  57.     return
  58.  
  59. reallyshoot:
  60.     energy fire' store
  61.     return
  62.  
  63. ••••••••••••••••••••••••••••••••••••
  64.  
  65. { MoveBot
  66.   Created 11/21/89 by David Harris.
  67.  
  68.     This robot moves about the screen, 
  69.     maintaining shields and searching for a
  70.     target.  It fires when it sights anything.
  71. }
  72.  
  73. START:
  74.     1 speedx' store                 
  75.     1 speedy' store
  76.        25 shield' store
  77.  
  78. MAIN:
  79.     aim 5 + aim' store              # Rotate Turret 
  80.     x 50 < xmin if                  # X minimum
  81.     y 50 < ymin if                  # Y minimum
  82.     x 250 > xmax if                 # X maximum
  83.     y 250 > ymax if                 # Y maximum
  84.     range 0 > shoot if              # Shoot if range >0
  85.         25 shield' store
  86.     main jump
  87.  
  88. XMIN:
  89.     random 3 mod 1 + speedx' store
  90.         return
  91.  
  92. YMIN:
  93.       random 3 mod 1 + speedy' store
  94.     return
  95.  
  96. XMAX:
  97.     -1 random 3 mod - speedx' store
  98.     return
  99.  
  100. YMAX:
  101.     -1 random 3 mod - speedy' store
  102.     return
  103.  
  104. SHOOT:
  105.         energy 2 / missile' store
  106.     return
  107.